//
//  HomeHeaderView.swift
//  LeGou
//
//  Created by lxm on 2022/9/19.
//

import UIKit

class HomeHeaderView: UIView {

    //MARK: --------------------属性--------------------
    
    //MARK: --------------------UI控件--------------------
                
    let poolView = ConsumePoolView()
            
    let homeCate = HomeCateView()
    
    let messageView = MessageView()
    
    let bannerView = BannerContentView()
    
    let homeTaskView = HomeTaskView()
    
    let redView = RedBagView()
    
    let stack = ZMUtil.stackView(axis: .vertical, spacing: 12)
    //MARK: --------------------生命周期--------------------
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
        bindAction()
        addConstraints()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setUI()
        bindAction()
        addConstraints()
    }

    //MARK: --------------------UI--------------------
    func setUI() {
        stack.addArrangedSubview(bannerView)
        if !AppHelper.appVerify() {
            stack.addArrangedSubview(messageView)
        }
        stack.addArrangedSubview(homeCate)
        
        if !AppHelper.appVerify() {
            // 审核隐藏
            stack.addArrangedSubview(redView)
            redView.isHidden = true
            stack.addArrangedSubview(poolView)
            stack.addArrangedSubview(homeTaskView)
        }
        

        addSubview(stack)
        
        stack.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-12).priority(.medium)
        }
        
        let s = systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
        layoutIfNeeded()
        let s1 = systemLayoutSizeFitting(UIView.layoutFittingCompressedSize)
        print("ff")
    }
        
    func addConstraints() {
        
    }
    
    override func layoutSubviews() {
        print(zm.size)
    }
    
    //MARK: --------------------methods--------------------
    func bindAction() {
        
    }
    //MARK: --------------------delegate--------------------

}
